package gr.atc.epart.googlewrapper.moderator;

import gr.atc.epart.googlewrapper.moderator.ModeratorSubmission;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class ModeratorTopic
{
	public static final String PLUS_VOTES = "plusVotes";
	public static final String MINUS_VOTES = "minusVotes";
	public static final String NONE_VOTES = "noneVotes";

	
	private int _id;
	private int _ownerSeriesId;
	private String	_name;
	private String	_description;
	private String	_presenter;
	private int	_numOfSubmissions; 
	private int	_numOfUsers;
	
	private ArrayList<ModeratorSubmission> _submissions;
	private HashMap<String, Integer> _counters;
	
	public ModeratorTopic(int id,int ownerSeriesId)
	{
		_id = id;
		_ownerSeriesId = ownerSeriesId;
		
		_counters = new HashMap<String, Integer>();
		_submissions = new ArrayList<ModeratorSubmission>();
		
		_counters.put(PLUS_VOTES, 0);
		_counters.put(MINUS_VOTES, 0);
		_counters.put(NONE_VOTES, 0);

	}
	
	public int getId()
	{
		return _id;
	}
	
	public int getOnwerSeriesId()
	{
		return _ownerSeriesId;
	}
	
	public void setName(String name)
	{
		_name = name;
	}
	
	public String getName()
	{
		return _name;
	}
		
	public void setDescription(String description)
	{
		_description = description; 	
	}
	
	public String getDescription()
	{
		return _description; 
	}
	
	public void setPresenter(String presenter)
	{
		_presenter = presenter;
	}
	
	public String getPresenter()
	{
		return _presenter;
	}

	public void setcounter(String tag,int value)
	{
		if (_counters.containsKey(tag))
		{
			_counters.put(tag, value);
		}
	}
	
	public int getCounter(String tag) throws Exception
	{
		if (_counters.containsKey(tag))
		{
			return _counters.get(tag);
		}
		else
		{
			throw new Exception("Counter name not be recognised");
		}
			
	}

	public void setNumOfSubmissions(int numofSubmissions)
	{
		_numOfSubmissions = numofSubmissions;
	}
	
	public int getNumOfSubmissions()
	{
		return _numOfSubmissions;
	}
	
	public void setNumOfUsers(int numofUsers)
	{
		_numOfUsers = numofUsers;
	}
	
	public int getNumOfUsers()
	{
		return _numOfUsers;
	}

	public void addSubmission(ModeratorSubmission	submission)
	{
		_submissions.add(submission);
	}
	
	public ArrayList<ModeratorSubmission> getSubmissionList()
	{
		return _submissions;
	}

	public void removeAllSubmissions()
	{
		// remove all submissions..
		_submissions.clear();
		_numOfSubmissions = 0;
		_numOfUsers = 0;
		_counters.put(PLUS_VOTES, 0);
		_counters.put(MINUS_VOTES, 0);
		_counters.put(NONE_VOTES, 0);
	}
}
